#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QtSql>
#include <QDataWidgetMapper>
#include <QFileDialog>
#include <QMessageBox>
#include "BComboxDelegate.h"

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

private:
    Ui::MainWindow *ui;

    QSqlDatabase m_db;              //数据库连接
    QSqlTableModel *m_tableModel;       //数据模型
    QItemSelectionModel *m_theSelection;  //选择模型
    QDataWidgetMapper *m_dataMapper;    //数据映射
    BComboxDelegate m_delegateSex;      //性别代理
    BComboxDelegate m_delegateDepart;   //部门代理

    void openTable();   //打开数据库
    void getFieldNames();    //获取字段名称，填充“排序字段”的comboBOx

private slots:

    void currentChanged(const QModelIndex& current, const QModelIndex& previous);
    void currentRowChanged(const QModelIndex& current, const QModelIndex& previous);
    void on_actOpenDB_triggered();
    void on_actRecAppend_triggered();
    void on_actRecInsert_triggered();
    void on_actRecDelete_triggered();
    void on_actSubmit_triggered();
    void on_actRevert_triggered();
    void on_radioBtnAscend_clicked();
    void on_radioBtnDescend_clicked();
    void on_radioBtnMan_clicked();
    void on_radioBtnWoman_clicked();
    void on_radioBtnBoth_clicked();
};
#endif // MAINWINDOW_H
